package com.gxa.xc.rbac.controller;

import com.gxa.xc.rbac.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.ArrayList;
import java.util.List;

/**
 * @author:IT-CNLM
 * @date:Created at 2020/10/20
 */
@Controller
@RequestMapping("/th")
public class ThymeleafController {


    /**
     * 渲染页面的方法
     * @return
     */
    @GetMapping("/show")
    public String show(Model model){
        // 模拟一个数据
        String name = "唐衡";
        // 给模型设置属性
        model.addAttribute("name", name);

        // 模拟集合传输
        List<User> users = new ArrayList<>();
        users.add(new User("郭富强",20, "男", "东莞"));
        users.add(new User("何小宇",21, "男", "广东"));
        users.add(new User("吴佳伦",21, "女", "西昌"));
        users.add(new User("彭筱惠",18, "女", "成都"));
        // 加入模型
        model.addAttribute("users", users);

        return "test";
    }



}
